//
//  NewFeatureController.swift
//  swift_demo_weibo
//
//  Created by 杨兵 on 15/5/14.
//  Copyright (c) 2015年 bing. All rights reserved.
//

import UIKit


class NewFeatureController: UICollectionViewController {

    @IBOutlet weak var layoutView: UICollectionViewFlowLayout!
    

    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        layoutView.itemSize = self.view.bounds.size
    }
    
    
    // 新特性4个
    let newfeaturenumber = 4


    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return newfeaturenumber
    }

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("NewFeatureCell", forIndexPath: indexPath) as! NewFeatureCell
    
        cell.selectIndex = indexPath.item + 1
    
        return cell
    }

    
    // 完成显示后执行动画
    override func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
        let path = collectionView.indexPathsForVisibleItems().last as! NSIndexPath
        
        // 到了最后一页
        if path.item == newfeaturenumber - 1 {
            let cellend = collectionView.cellForItemAtIndexPath(path) as! NewFeatureCell
            cellend.showBtn()
        }
    }
    
    
    // 隐藏状态栏
    override func prefersStatusBarHidden() -> Bool {
        return true
    }
    

}
